#pragma once
#include "PMesh.h"

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#include <emscripten/bind.h>
#include <emscripten/val.h>
#endif

namespace MeshProcessing {
	class PMeshManager {
	public:
		static float* allocateVertexBuffer(uint vertextBufferLength);

		static uint* allocateIndicesBuffer(uint indexBufferLength);

	public:
		static PMeshManager* getManager() {
			static PMeshManager m_instance;
			return &m_instance;
		}

		static Handle allocateBuffer(uint num, uint type); // type: 0=vertexs, 1=indices
		static PMesh* createPMesh();

		static void destroyMesh(PMesh* mesh);
		static void destroyPMesh(Handle mesh);

	private:
		PMeshManager() = default;
	};
}